package com.sky.category.api.client.conf;

import com.sky.context.BaseContext;
import feign.RequestInterceptor;
import org.springframework.context.annotation.Bean;

/**
 * feign的默认配置
 */
public class DefaultFeignConf {

    @Bean
    public RequestInterceptor requestInterceptor() {

        return requestTemplate -> {

            Long userId = BaseContext.getCurrentId();
            if (userId != null) {
                requestTemplate.header("user-info", String.valueOf(userId));
            }

        };

    }

}
